<!doctype html>
<html lang="en">
  <head>
    <meta charset="utf-8">
    <title>Server Power Management</title>
    <link rel="stylesheet" type="text/css" href="{{ url_for('static', filename='style.css') }}">
  </head>
  <body>
    <h1>Server Power Management</h1>
    <a href="{{ url_for('add_server') }}">Add Server</a>
    <table border="1">
      <thead>
        <tr>
          <th>Hostname</th>
          <th>BMC IP</th>
          <th>Username</th>
          <th>Password</th>
          <th>Use LAN Plus</th>
          <th>Power Status</th>
          <th>Action</th>
          <th>Edit</th>
          <th>Delete</th>
        </tr>
      </thead>
      <tbody>
        {% for server in servers %}
        <tr>
          <td>{{ server.hostname }}</td>
          <td>{{ server.bmc_ip }}</td>
          <td>{{ server.username }}</td>
          <td>{{ server.password }}</td>
          <td>{{ server.use_lanplus }}</td>
          <td>{{ server.powerstat }}</td>
          <td>
            {% if server.powerstat == 'power on' %}
	    <a href="{{ url_for('power_action', id=server.id, action='soft') }}">Soft Power Off</a>
	    &nbsp;|&nbsp;
            <a href="{{ url_for('power_action', id=server.id, action='off') }}">Hard Power Off</a>
            {% elif server.powerstat == 'power off' %}
            <a href="{{ url_for('power_action', id=server.id, action='on') }}">Power On</a>
            {% else %}
            Unknown
            {% endif %}
          </td>
          <td><a href="{{ url_for('edit_server', id=server.id) }}">Edit</a></td>
          <td>
            <form method="POST" action="{{ url_for('delete_server', id=server.id) }}" style="display:inline;">
              <button type="submit">Delete</button>
            </form>
          </td>
        </tr>
        {% endfor %}
      </tbody>
    </table>
  </body>
</html>

